﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataAccess;
using System.Data;
using Entity;

namespace Bussiness
{
    public class PostBll
    {
        private PostDao _postDao;
        
        public DataSet GetPostById(int postId)
        {
            _postDao = new PostDao();
            return _postDao.GetPostById(postId);
        }

        public DataSet GetNewPost(int numberOfPost)
        {
            _postDao = new PostDao();
            return _postDao.GetNewPost(numberOfPost);
        }

        public bool AddPost(Post post)
        {
            _postDao = new PostDao();
            int result = _postDao.AddPost(post);
            return (result != 0);
        }

        public bool UpdatePost(Post post)
        {
            _postDao = new PostDao();
            int result = _postDao.UpdatePost(post);
            return (result != 0);
        }

        public DataSet GetPostByCategoryId(int categoryId)
        {
            _postDao = new PostDao();
            return _postDao.GetPostByCategoryId(categoryId);
        }

        public DataSet GetPostByUser(string userName)
        {
            _postDao = new PostDao();
            return _postDao.GetPostByUserName(userName);
        }

        public DataSet GetPostByDate(string postDate)
        {
            _postDao = new PostDao();
            return _postDao.GetPostByDate(postDate);
        }

        public DataSet GetTopViewPost(int numberOfPost)
        {
            _postDao = new PostDao();
            return _postDao.GetTopViewPost(numberOfPost);
        }

        public DataSet GetTopCommentPost(int numberOfPost)
        {
            _postDao = new PostDao();
            return _postDao.GetTopCommentPost(numberOfPost);
        }

        public void UpdatePostViewCount(int postId)
        {
            _postDao = new PostDao();
            _postDao.UpdatePostView(postId);
        }
        public void UpdatePostCommentCount(int postId)
        {
            _postDao = new PostDao();
            _postDao.UpdateCommentCount(postId);
        }
    }
}
